package com.servlet.filters;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * @author wzm
 * @create 2024-02-20 10:26
 * project_name:JavaWeb2401
 * @Description
 */
@WebFilter("/*")//拦截所有请求
//@WebFilter("/index.jsp")//只拦截index.jsp
//@WebFilter("/student/*")//只拦截路径为/student/任何请求
//@WebFilter("*.html")//只拦截html结尾的请求
public class HelloFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    //过滤器执行的方法  拦截的方法
    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        System.out.println("请求被拦截了1");
        //放行
        chain.doFilter(request,response);
        System.out.println("放行后1");
    }

    @Override
    public void destroy() {

    }
}
